// Copyright@ChenChao


#include "Player/CPlayerController.h"

#include "Blueprint/UserWidget.h"
#include "Player/CPlayerCharacter.h"
#include "UI/Widget/GameplayWidget.h"

void ACPlayerController::AcknowledgePossession(class APawn* P)
{
	Super::AcknowledgePossession(P);
	CPlayerCharacter = Cast<ACPlayerCharacter>(P);
	if (CPlayerCharacter)
	{
		CPlayerCharacter->ClientSideInit();
		SpawnGameplayWidget();
	}
	
}

void ACPlayerController::SpawnGameplayWidget()
{
	if (!IsLocalPlayerController()) return;

	//创建游戏玩法小部件
	GameplayWidget = CreateWidget<UGameplayWidget>(this, GameplayWidgetClass);
	if (GameplayWidget)
	{
		GameplayWidget->AddToViewport();		//添加到视口
	}
}
